{% extends 'custom_admin/base.html' %}

{% block title %}终审文章{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <h2>终审文章</h2>
            
            <!-- 文章信息 -->
            <div class="card mb-4">
                <div class="card-header">
                    <h5>文章信息</h5>
                </div>
                <div class="card-body">
                    <p><strong>标题:</strong> {{ article.title }}</p>
                    <p><strong>作者:</strong> {{ article.author.username }}</p>
                    <p><strong>状态:</strong> {{ article.get_status_display }}</p>
                    <p><strong>初审时间:</strong> {{ article.first_reviewed_at|date:"Y-m-d H:i" }}</p>
                </div>
            </div>
            
            <!-- 文章内容 -->
            <div class="card mb-4">
                <div class="card-header">
                    <h5>文章内容</h5>
                </div>
                <div class="card-body">
                    {{ article.content|linebreaks }}
                </div>
            </div>
            
            <!-- 审核历史 -->
            {% if review_history %}
            <div class="card mb-4">
                <div class="card-header">
                    <h5>审核历史</h5>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-striped">
                            <thead>
                                <tr>
                                    <th>审核人</th>
                                    <th>操作</th>
                                    <th>审核前状态</th>
                                    <th>审核后状态</th>
                                    <th>备注</th>
                                    <th>时间</th>
                                </tr>
                            </thead>
                            <tbody>
                                {% for review in review_history %}
                                <tr>
                                    <td>{{ review.reviewer.username }}</td>
                                    <td>{{ review.action }}</td>
                                    <td>{{ review.get_status_before_display }}</td>
                                    <td>{{ review.get_status_after_display }}</td>
                                    <td>{{ review.comment }}</td>
                                    <td>{{ review.created_at|date:"Y-m-d H:i" }}</td>
                                </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            {% endif %}
            
            <!-- 审核表单 -->
            <div class="card">
                <div class="card-header">
                    <h5>终审操作</h5>
                </div>
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}
                        <div class="mb-3">
                            <label for="{{ form.action.id_for_label }}" class="form-label">审核操作:</label>
                            {{ form.action }}
                        </div>
                        <div class="mb-3">
                            <label for="{{ form.comment.id_for_label }}" class="form-label">审核备注:</label>
                            {{ form.comment }}
                        </div>
                        <div class="btn-group" role="group">
                            <button type="submit" class="btn btn-primary">提交审核</button>
                            <a href="{% url 'custom_admin:article_review_list' %}" class="btn btn-secondary">取消</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}